import re

# match
mode = re.compile("w+", re.IGNORECASE)
data = "wWw.imooc.com www"
a = re.match(mode, data)
print(a.group(), a.start(), a.end(), a.span())
print(re.findall(mode, data))
print(mode.findall(data, 2))
print()
b = re.search("o+", "www.imooc.com")
c = re.search("^a", "abc")
d = re.search("c$", "abc")
e = re.search("\d+", "abc123xyz")
f = re.search("\d{3}", "abc123xyz")

# replace
line = "number=123 # this is comment 456 789"
result = re.sub("\d+", "NUMBER", line, 2)
print(result)

# split
g = re.split("[: -]", "2001-02-03 19:34:57")
print(g)
